package yuhao.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Jdbc6 {
    public static void main(String[] args) throws Exception {

        // 1.注册驱动
        //Class.forName("com.mysql.jdbc.Driver");


        // 2.获取数据库连接
        String url = "jdbc:mysql://127.0.0.1/db6?useSSL=false";
        String username = "root";
        String password = "1234";
        Connection conn = DriverManager.getConnection(url, username, password);
        String name = "zhangsan";
        String psd = "'or'2'='2";

        String sql = "select * from tb_user where username='"+ name +" ' and password= '"+ psd +"' ";
        Statement sta = conn.createStatement();
        ResultSet resultSet = sta.executeQuery(sql);
        if (resultSet.next()) {
            System.out.println("登陆成功");
        } else {
            System.out.println("登录失败");
        }

    }


}

